﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;

namespace ServiceOfSansar.Auth
{
    class AuthorizationManager : ServiceAuthorizationManager
    {
        private string[] skip = new string[] { "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get", "Sansar/Master/Login", "Sansar/Master/Test", "Sansar/Register/RoleAndPermissionList", "Sansar/Enquiry/ContractDetail" };
        public override bool CheckAccess(OperationContext context)
        {
            if (skip.Contains(OperationContext.Current.IncomingMessageHeaders.Action))
                return true;

            TokenManager.Kills();
            XmlDictionaryReader hdr=context.IncomingMessageHeaders.GetReaderAtHeader(1);
            string token=hdr.NamespaceURI;            
            return TokenManager.CheckAccess(token);
        }
    }
}
